package com.wardrobe.soa.api.goods_classify;

import com.wardrobe.domain.booking.BookingShowBean;
import com.wardrobe.domain.goods_classify.ClassifyGoodShowBean;
import com.wardrobe.domain.goods_classify.GoodsClassifyBean;
import com.wardrobe.soa.common.ApiResult;
import com.wardrobe.soa.utils.CommonConsant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018/11/20.
 */
@RestController
@RequestMapping("/api/goodsclassify")
public class GoodsClassifyController {
    private static final Logger logger = LoggerFactory.getLogger(GoodsClassifyController.class);
    @Autowired
    private GoodsClassifyService goodsClassifyService;

    @RequestMapping("/goodsClassifyList")
    public ApiResult getGoodsClassifyList(){
        try {
            List<GoodsClassifyBean> list = goodsClassifyService.getGoodsClassifyList();
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,list);
        }catch (Exception e){
            logger.error("goodsClassifyList",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }

    @RequestMapping("/getClassifyGoods")
    public ApiResult getClassifyGoods(int classifyId){
        try {
            List<ClassifyGoodShowBean> list = goodsClassifyService.getClassifyGoods(classifyId);
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,list);
        }catch (Exception e){
            logger.error("goodsClassifyList",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }
}
